<template>
  <el-card class="page-tools">
    <el-row type="flex" justify="space-between">
      <el-col>
        <div v-if="$slots.before" class="before">
          <i class="el-icon-info" />
          <slot age="18" node="测试" :row="list.length" name="before" />
        </div>
      </el-col>
      <el-col>
        <el-row type="flex" justify="end">
          <slot name="after" />
        </el-row>
      </el-col>
    </el-row>
  </el-card>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => ([])
    }
  },
  mounted() {
    // mounted里面dom已经挂载完毕了
    // 可以获取到真实的dom了

    // 就算不传自定义的属性
    // $slots包含调用当前组件时候传递的所有插槽
    // 也可以通过$slots判断是否包含before插槽
    console.log(this.$slots)
  }
}
</script>

<style scoped lang="scss">
.page-tools {
  margin: 10px 0;

  .before {
    line-height: 34px;
    i {
      margin-right: 5px;
      color: #409eff;
    }
    display: inline-block;
    padding: 0 10px;
    border-radius: 3px;
    border: 1px solid rgba(145, 213, 255, 1);
    background: rgba(230, 247, 255, 1);
    font-size: 12px;
  }
}
</style>

